package com.example.fragmentdemo;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;


public class DynamicFragment extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        MyViewModel.getInstance().getStr(this, new Observer<String>() {
            @Override
            public void onChanged(String s) {
                Toast.makeText(requireActivity(),s,Toast.LENGTH_LONG).show();
            }
        });
        // Inflate the layout for this fragment
       View rootView=inflater.inflate(R.layout.fragment_dynamic, container, false);
       intiView(rootView);
       return  rootView;
    }
    private void intiView(View view){
        view.findViewById(R.id.text_dynamic);
    }
}